package com.ruoyi.project.gxgw_modules.discountManager.controller;

import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.gxgw_modules.discountManager.domain.YhqOwner;
import com.ruoyi.project.gxgw_modules.discountManager.service.IYhqOwnerService;
import com.ruoyi.project.gxgw_modules.discountManager.vo.YhqOwnerVO;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 用户及其优惠券 信息操作处理
 * 
 * @author ruoyi
 * @date 2019-01-25
 */
@Controller
@RequestMapping("/gxgw_modules/yhqOwner")
public class YhqOwnerController extends BaseController
{
    private String prefix = "gxgw_modules/yhqOwner";
	
	@Autowired
	private IYhqOwnerService yhqOwnerService;
	
	@RequiresPermissions("gxgw_modules:yhqOwner:view")
	@GetMapping()
	public String yhqOwner()
	{
	    return prefix + "/yhqOwner";
	}
	
	/**
	 * 查询用户及其优惠券列表
	 */
	@RequiresPermissions("gxgw_modules:yhqOwner:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(YhqOwnerVO yhqOwnerVO)
	{
		startPage();
        List<YhqOwnerVO> list = yhqOwnerService.selectYhqOwnerList(yhqOwnerVO);
		return getDataTable(list);
	}
	
	
	/**
	 * 导出用户及其优惠券列表
	 */
	@RequiresPermissions("gxgw_modules:yhqOwner:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(YhqOwnerVO yhqOwnerVO)
    {
    	List<YhqOwnerVO> list = yhqOwnerService.selectYhqOwnerList(yhqOwnerVO);
        ExcelUtil<YhqOwnerVO> util = new ExcelUtil<YhqOwnerVO>(YhqOwnerVO.class);
        return util.exportExcel(list, "yhqOwner");
    }
	
/*	*//**
	 * 新增用户及其优惠券
	 *//*
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	*//**
	 * 新增保存用户及其优惠券
	 *//*
	@RequiresPermissions("gxgw_modules:yhqOwner:add")
	@Log(title = "用户及其优惠券", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(YhqOwner yhqOwner)
	{		
		return toAjax(yhqOwnerService.insertYhqOwner(yhqOwner));
	}*/

	/**
	 * 修改用户及其优惠券
	 */
	@GetMapping("/edit/{ownerId}")
	public String edit(@PathVariable("ownerId") Integer ownerId, ModelMap mmap)
	{
		YhqOwner yhqOwner = yhqOwnerService.selectYhqOwnerById(ownerId);
		mmap.put("yhqOwner", yhqOwner);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存用户及其优惠券
	 */
	@RequiresPermissions("gxgw_modules:yhqOwner:edit")
	@Log(title = "用户及其优惠券", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(YhqOwner yhqOwner)
	{		
		return toAjax(yhqOwnerService.updateYhqOwner(yhqOwner));
	}
	
	/**
	 * 删除用户及其优惠券
	 */
	@RequiresPermissions("gxgw_modules:yhqOwner:remove")
	@Log(title = "用户及其优惠券", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(yhqOwnerService.deleteYhqOwnerByIds(ids));
	}
	
}
